/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Splash.java * * Created on Jan 11, 2011, 4:00:12 PM */ package com.github.couchapptakeout.ui; import com.github.couchapptakeout.events.LoadingMessage; import java.awt.Dimension; import java.awt.Toolkit; import org.bushe.swing.event.EventBus; import org.bushe.swing.event.EventSubscriber; /** * * @author ryan */ public class Splash extends javax.swing.JWindow { /** Creates new form Splash */ public Splash(String appName) { initComponents(); appNameLabel.setText(appName); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); int screenHeight = screenSize.height; int screenWidth = screenSize.width; int width = 278; int height = 200; setSize(width, height); setLocation((screenWidth/2) - (width/2), (screenHeight /2) - (height /2)); EventBus.subscribeStrongly(LoadingMessage.class, new EventSubscriber<LoadingMessage>() { @Override public void onEvent(LoadingMessage t) { if (t.getStatusTotal() == 0) { progressBar.setIndeterminate(true); } else { progressBar.setIndeterminate(false); progressBar.setMinimum(1); progressBar.setMaximum(t.getStatusTotal()); progressBar.setValue(t.getStatusProgress()); } statusLabel.setText(t.getStepDesc()); } }); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); statusLabel = new javax.swing.JLabel(); progressBar = new javax.swing.JProgressBar(); appNameLabel = new javax.swing.JLabel(); setBackground(new java.awt.Color(255, 255, 255)); jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true)); jPanel1.setLayout(new java.awt.BorderLayout()); statusLabel.setBackground(new java.awt.Color(255, 255, 255)); statusLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); statusLabel.setText("Please Wait..."); statusLabel.setMaximumSize(new java.awt.Dimension(278, 200)); statusLabel.setOpaque(true); jPanel1.add(statusLabel, java.awt.BorderLayout.CENTER); progressBar.setIndeterminate(true); progressBar.setMaximumSize(new java.awt.Dimension(200, 14)); jPanel1.add(progressBar, java.awt.BorderLayout.SOUTH); appNameLabel.setBackground(new java.awt.Color(255, 255, 255)); appNameLabel.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N appNameLabel.setText("App Name"); appNameLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 10, 3, 1)); appNameLabel.setOpaque(true); jPanel1.add(appNameLabel, java.awt.BorderLayout.PAGE_START); getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Splash("App Name").setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel appNameLabel; private javax.swing.JPanel jPanel1; private javax.swing.JProgressBar progressBar; private javax.swing.JLabel statusLabel; // End of variables declaration//GEN-END:variables }